﻿//using HZH_Controls.Controls;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;

namespace com.sddemo.uikit.controls
{
    public partial class AChart : Panel
    {
        //全局变量
        public enum CurveTypeS
        {
            Client = 0,
            Product = 1,
            Stimulate = 2,
            IO=3
        }

        public struct LinePoint
        {
            public LinePoint(int pvX, int pvY, bool pvIsMasked)
            {
                X = pvX;
                Y = pvY;
                IsMasked = pvIsMasked;
            }


            public int X;
            public int Y;
            public bool IsMasked;

        }

        //线上的点
        public struct CurvePoint
        {
            public CurvePoint(int pvX, double pvY)
            {
                X = pvX;
                Y = pvY;
            }
            public int X;
            public double Y;
        }

        private CurveList mvarCurveList = new CurveList();
        private int[] mArrFreqList = new int[145];

        ////事件
        //public event EventHandler Click = null;

        //private const int m_Const_BianjuX = 200;
        //private const int m_Const_BianjuY = 200;

        //private long m_lngX = 0;
        //private long m_lngY = 0;
        //private string m_strPoints = "";

        int fontsize = 9;
        string fontfamily = "宋体";//"微软雅黑";
        private Color m_FontNormalColor = ColorTranslator.FromHtml("#404457");

        private string m_EarFlag = "Right";
        private bool m_IsEdit = true;
        private int m_CurveColor = 0;
        private bool m_IsMasked = false;
        private string m_CurrControlType = "A";//     'A:气导 B: 骨导 L:不舒适阈 M:舒适阈
        private string m_LossDatas = "";
        private string m_BossDatas = "";
        private string m_LimitDatas = "";
        private string m_MCLDatas = "";
        private int m_CurveWidth = 1;
        private int m_DrawWidth = 1;
        private string m_Xnames = "125//250//500//1k//2k//4k//8k/12k";//"125//250//500//1k//2k//4k//8k//16k";
        private string m_Ynames = "70//60//50//40//30//20//10";//"0//20//40//60//80//100//120";
        private int m_ForeColorNew = 0;
        private bool m_EnabledNew = true;
        private Font m_FontNew;
        private string m_YTitle = "";
        private string m_XTitle = "";


        private int m_XYBackColor = 16777215;
        private int m_ScaleHeight = 0;
        private int m_ScaleWidth = 0;
        private int m_ScaleLeft = 0;
        private int m_ScaleTop = 0;
        private int m_GridColor = 14737632;
        private int m_XPointCount = 13;
        private int m_YPointCount = 12;
        private int m_XGridTick = 1;
        private int m_YGridTick = 1;
        private int m_YPointValue = 10;
        private int m_XPointValue = 1;
        private int m_YMaxValue = 70;//120;
        private int m_YMinValue = 10;//0;
        private int m_XMaxValue = 12000;//12;
        private int m_XMinValue = 125;//0;
        private int m_BackLightColor = 16577775;
        private int m_BackDarkColor = 16443612;
        private string m_ProUpline;
        private string m_ProDownline;
        private int m_intRegionBeginFreq = 0;
        private int m_intRegionEndFreq = 0;
        private Color m_RegionColor = Color.FromArgb(210, 250, 250);
        private double[] m_CrossFrequency = new double[15];
        private bool[] m_SelectChannel = new bool[16];

        //是否显示增益最大区域
        private bool m_IsShowMaxGainRegion = false;
        private double[] m_ArrMaxGainFreqList = new double[] { };
        private double[] m_ArrMaxGainDataList = new double[] { };
        private int m_TopBianju = 13;
        private Color m_MaxGainRegionColor = Color.LightGray;


        //属性
        private CurveTypeS m_CurveType = CurveTypeS.Client;

        public CurveTypeS CurveType
        {
            get
            {
                return m_CurveType;
            }
            set
            {
                m_CurveType = value;
                //重新画图
                switch (m_CurveType)
                {
                    case CurveTypeS.Client:
                        break;
                    case CurveTypeS.Product:
                        break;
                    case CurveTypeS.Stimulate:
                        break;
                    default:
                        break;
                }

            }
        }
        public bool IsEdit
        {
            get
            {
                return m_IsEdit;
            }
            set
            {
                m_IsEdit = value;
            }
        }
        public bool IsMasked
        {
            get
            {
                return m_IsMasked;
            }
            set
            {
                m_IsMasked = value;
            }
        }
        public string CurrControlType
        {
            get
            {
                return m_CurrControlType;
            }
            set
            {
                m_CurrControlType = value;
            }
        }
        public int CurveColor
        {
            get
            {
                return m_CurveColor;
            }
            set
            {
                m_CurveColor = value;
            }
        }
        public string EarFlag
        {
            get
            {
                return m_EarFlag;
            }
            set
            {
                m_EarFlag = value;
            }
        }
        public string LossDatas
        {
            get
            {
                return m_LossDatas;
            }
            set
            {
                m_LossDatas = value;
            }
        }
        public string BossDatas
        {
            get
            {
                return m_BossDatas;
            }
            set
            {
                m_BossDatas = value;
            }
        }
        public string LimitDatas
        {
            get
            {
                return m_LimitDatas;
            }
            set
            {
                m_LimitDatas = value;
            }
        }
        public string MCLDatas
        {
            get
            {
                return m_MCLDatas;
            }
            set
            {
                m_MCLDatas = value;
            }
        }
        public int CurveWidth
        {
            get
            {
                return m_CurveWidth;
            }
            set
            {
                m_CurveWidth = value;
            }
        }
        public int DrawWidth
        {
            get
            {
                return m_DrawWidth;
            }
            set
            {
                m_DrawWidth = value;
            }
        }
        public string Xnames
        {
            get
            {
                return m_Xnames;
            }
            set
            {
                m_Xnames = value;
            }
        }
        public string Ynames
        {
            get
            {
                return m_Ynames;
            }
            set
            {
                m_Ynames = value;
            }
        }
        public int ForeColorNew
        {
            get
            {
                return m_ForeColorNew;
            }
            set
            {
                m_ForeColorNew = value;
            }
        }
        public bool EnabledNew
        {
            get
            {
                return m_EnabledNew;
            }
            set
            {
                m_EnabledNew = value;
            }
        }
        public Font FontNew
        {
            get
            {
                return m_FontNew;
            }
            set
            {
                m_FontNew = value;
            }
        }
        public string YTitle
        {
            get
            {
                return m_YTitle;
            }
            set
            {
                m_YTitle = value;
            }
        }
        public string XTitle
        {
            get
            {
                return m_XTitle;
            }
            set
            {
                m_XTitle = value;
            }
        }
        public int XYBackColor
        {
            get
            {
                return m_XYBackColor;
            }
            set
            {
                m_XYBackColor = value;
            }
        }
        public int ScaleHeight
        {
            get
            {
                return m_ScaleHeight;
            }
            set
            {
                m_ScaleHeight = value;
            }
        }
        public int ScaleWidth
        {
            get
            {
                return m_ScaleWidth;
            }
            set
            {
                m_ScaleWidth = value;
            }
        }
        public int ScaleLeft
        {
            get
            {
                return m_ScaleLeft;
            }
            set
            {
                m_ScaleLeft = value;
            }
        }
        public int ScaleTop
        {
            get
            {
                return m_ScaleTop;
            }
            set
            {
                m_ScaleTop = value;
            }
        }
        public int GridColor
        {
            get
            {
                return m_GridColor;
            }
            set
            {
                m_GridColor = value;
            }
        }
        public int XPointCount
        {
            get
            {
                return m_XPointCount;
            }
            set
            {
                m_XPointCount = value;
            }
        }
        public int YPointCount
        {
            get
            {
                return m_YPointCount;
            }
            set
            {
                m_YPointCount = value;
            }
        }
        public int XGridTick
        {
            get
            {
                return m_XGridTick;
            }
            set
            {
                m_XGridTick = value;
            }
        }
        public int YGridTick
        {
            get
            {
                return m_YGridTick;
            }
            set
            {
                m_YGridTick = value;
            }
        }
        public int XPointValue
        {
            get
            {
                return m_XPointValue;
            }
            set
            {
                m_XPointValue = value;
            }
        }
        public int YPointValue
        {
            get
            {
                return m_YPointValue;
            }
            set
            {
                m_YPointValue = value;
            }
        }
        public int YMaxValue
        {
            get
            {
                return m_YMaxValue;
            }
            set
            {
                m_YMaxValue = value;
            }
        }
        public int XMaxValue
        {
            get
            {
                return m_XMaxValue;
            }
            set
            {
                m_XMaxValue = value;
            }
        }
        public int YMinValue
        {
            get
            {
                return m_YMinValue;
            }
            set
            {
                m_YMinValue = value;
            }
        }
        public int XMinValue
        {
            get
            {
                return m_XMinValue;
            }
            set
            {
                m_XMinValue = value;
            }
        }
        public int BackLightColor
        {
            get
            {
                return m_BackLightColor;
            }
            set
            {
                m_BackLightColor = value;
            }
        }
        public int BackDarkColor
        {
            get
            {
                return m_BackDarkColor;
            }
            set
            {
                m_BackDarkColor = value;
            }
        }
        public string Upline
        {
            get
            {
                return m_ProUpline;
            }
            set
            {
                m_ProUpline = value;

                //If m_CurveType = Product Then
                //    Call RefreshProArea
                //End If
            }
        }
        public string Downline
        {
            get
            {
                return m_ProDownline;
            }
            set
            {
                m_ProDownline = value;
                //If m_CurveType = Product Then
                //    Call RefreshProArea
                //End If
            }
        }

        public CurveList Curves
        {
            get
            {
                return mvarCurveList;
            }
        }

        public int RegionBeginFreq
        {
            get
            {
                return m_intRegionBeginFreq;
            }
            set
            {
                m_intRegionBeginFreq = value;
            }
        }

        public int RegionEndFreq
        {
            get
            {
                return m_intRegionEndFreq;
            }
            set
            {
                m_intRegionEndFreq = value;
            }
        }

        public Color RegionColor
        {
            get
            {
                return m_RegionColor;
            }
            set
            {
                m_RegionColor = value;
            }
        }

        public Color MaxGainRegionColor
        {
            get
            {
                return m_MaxGainRegionColor;
            }
            set
            {
                m_MaxGainRegionColor = value;
            }
        }

        public double[] MaxGainFreList 
        {
            get
            {
                return m_ArrMaxGainFreqList;
            }
            set
            {
                m_ArrMaxGainFreqList = value;
            }
        }

        public double[] MaxGainDataList
        {
            get
            {
                return m_ArrMaxGainDataList;
            }
            set
            {
                m_ArrMaxGainDataList = value;
            }
        }

        //构造函数
        public AChart()
        {
            InitializeComponent();
            for(int i=0;i<m_SelectChannel.Length;i++)
            {
                m_SelectChannel[i] = false;
            }
        }

        /// <summary>
        /// 是否显示最大增益区域
        /// </summary>
        public bool IsShowMaxGainRegion
        {
            get
            {
                return m_IsShowMaxGainRegion;
            }
            set
            {
                m_IsShowMaxGainRegion = value;
            }
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
        }

        //设置频率点
        public void SetCrossFreqList(double[] pvCrossFreqValues)
        {
            m_CrossFrequency = new double[pvCrossFreqValues.Length];
            for(int i=0;i<pvCrossFreqValues.Length;i++)
            {
                m_CrossFrequency[i] = pvCrossFreqValues[i];
            }
        }

        //设置选中的通道
        public void SetSelectChannel(bool[] pvSelectChannel)
        {
            int intBeginChannel=-1;
            int intEndChannel = -1;
            for(int i=0;i<pvSelectChannel.Length;i++)
            {
                m_SelectChannel[i] = pvSelectChannel[i];
            }

            for(int i=0;i<pvSelectChannel.Length;i++)
            {
                if(m_SelectChannel[i]==true)
                {
                    intBeginChannel = i;
                    break;
                }
            }

            for(int i=pvSelectChannel.Length-1;i>=0;i--)
            {
                if(m_SelectChannel[i]==true)
                {
                    intEndChannel = i;
                    break;
                }
            }

            if (intBeginChannel == -1)
            {
                m_intRegionBeginFreq = 0;
                m_intRegionEndFreq = 0;
            }
            else
            {
                if(intBeginChannel==0)
                {
                    m_intRegionBeginFreq = 1;
                }
                else
                {
                    m_intRegionBeginFreq = (int)m_CrossFrequency[intBeginChannel - 1];
                }                
            } 
            
            if(intEndChannel==-1)
            {
                m_intRegionBeginFreq = 0;
                m_intRegionEndFreq = 0;
            }
            else
            {
                if (intEndChannel == m_CrossFrequency.Length)
                {
                    m_intRegionEndFreq = 12000;
                }
                else
                {
                    m_intRegionEndFreq = (int)m_CrossFrequency[intEndChannel];
                }
            }

            RefreshGraph();
        }

        //清除选中通道
        public void ClearSelectChannel()
        {
            m_intRegionBeginFreq = 0;
            m_intRegionEndFreq = 0;
        }

        //清除图形
        public void ClearAxis()
        {
            Image image = picBack.Image;
            picBack.Image = null;
            //image.Dispose();

            Image image1 = picGraph.Image;
            picGraph.Image = null;
            //image1.Dispose();

            //Graphics g = picXY.CreateGraphics();
            //g.Clear(Color.White);
            Image image2 = picXY.Image;
            picXY.Image = null;
            //image2.Dispose();



            //Set picBack.Picture = Nothing
            //Set picGraph.Picture = Nothing
            //picXY.Cls
        }

        public void ClearGraph()
        {
            Image image1 = picGraph.Image;
            picGraph.Image = null;
            //image1.Dispose();
        }

        // 画坐标轴(Y坐标从小到大)
        public void DrawUpAxis()
        {
            switch(m_CurveType)
            {
                case CurveTypeS.Client:
                    DrawUpAxis_FreqGain();
                    break;

                case CurveTypeS.IO:
                    DrawUpAxis_IO();
                    break;
                default:
                    DrawUpAxis_FreqGain();
                    break;
            }

        }

        //适配范围图
        private void DrawMaxGainRegionGraph(Graphics pvGraphics)
        {
            int i = 0;
            int intX;
            float fY;
            //int intDownY;
            //float fltX;
            //float fltY;
            double X1;
            double Y1;

            if (m_ArrMaxGainFreqList.Length == 0) return;


            PointF[] myPoints = new PointF[m_ArrMaxGainFreqList.Length+3];
            PointF[] myRealDataPoints = new PointF[myPoints.Count()];

            myPoints[0].X = (float)m_ArrMaxGainFreqList[0];
            myPoints[0].Y = (float)m_YMaxValue;

            myPoints[1].X = (float)12000;
            myPoints[1].Y = (float)m_YMaxValue;

            myPoints[2].X = (float)12000;
            myPoints[2].Y = (float)m_ArrMaxGainDataList[m_ArrMaxGainDataList.Length - 1];

            for (i=0;i<m_ArrMaxGainFreqList.Length;i++)
            {
                myPoints[i + 3].X = (float)m_ArrMaxGainFreqList[m_ArrMaxGainFreqList.Length - i-1];
                myPoints[i + 3].Y = (float)m_ArrMaxGainDataList[m_ArrMaxGainDataList.Length - i - 1];
            }


            myRealDataPoints = new PointF[myPoints.Count()];

            for (i = 0; i < myPoints.Count(); i++)
            {
                intX = (int)myPoints[i].X;
                fY = myPoints[i].Y;


                X1 = SimpleFreqLogOperation(intX);
                Y1 = (double)(m_TopBianju + (float)(picGraph.Height - 2 * m_TopBianju) - ((float)(picGraph.Height - 2 * m_TopBianju) / (m_YMaxValue - m_YMinValue)) * (fY - m_YMinValue));

                myRealDataPoints[i].X = (float)X1;
                myRealDataPoints[i].Y = (float)Y1;
            }

            //Brush brush = new SolidBrush(Color.FromArgb((int)(255 * 0.3),223,223,223));

            //Brush brush = new SolidBrush(Color.FromArgb((int)(255 * 0.07), ColorTranslator.FromHtml("#000000")));

            Brush brush = new SolidBrush(m_MaxGainRegionColor);
            //Brush brush = new SolidBrush(Color.FromArgb((int)(100), Color.Black));


            //Brush brush = new SolidBrush(Color.FromArgb(223, 223, 223));
            pvGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            //pvGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //pvGraphics.CompositingQuality = CompositingQuality.HighQuality;

            //pvGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            //pvGraphics.FillClosedCurve(brush, myRealDataPoints, System.Drawing.Drawing2D.FillMode.Winding, 0.5F);
            pvGraphics.FillClosedCurve(brush, myRealDataPoints, System.Drawing.Drawing2D.FillMode.Winding, 0F);
            //pvGraphics.FillClosedCurve(brush, myRealDataPoints);

        }

        //频点对数运算 传入频点，算出坐标位置
        private double SimpleFreqLogOperation(int pvFreq)
        {
            double dblCoordinateValue = 0;
            dblCoordinateValue = (double)(m_TopBianju + (Math.Log((float)(pvFreq) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * m_TopBianju));

            return dblCoordinateValue;
        }

        private void DrawUpAxis_FreqGain()
        {
            long lRet;
            float lRetNew;
            long lAdjustHeight;
            int i;
            string strValue;
            int j;
            long lYSpacing;
            long lXSpacing;
            float lXSpacingNew;
            float lYSpacingNew;
            //string [] ArrXNames;
            //string [] ArrYNames;
            int lngScaleHeight;
            int lngScaleWidth;
            Graphics g;
            Pen p;
            Brush bsh;
            Point pt1 = new Point();
            Point pt2 = new Point();

            PointF pt1New = new PointF();
            PointF pt2New = new PointF();

            string[] ArrXNames = new string[] { };
            string[] ArrYNames = new string[] { };

            int intBeginFreq = 0;
            int intEndFreq = 0;
            int X = 0;
            double X1;
            double Y1;
            double X2;
            double Y2;
            int intCount = 0;


            if (m_Xnames.Trim() != "")
            {
                ArrXNames = m_Xnames.Split('/');
            }
            if (m_Ynames.Trim() != "")
            {
                ArrYNames = m_Ynames.Split('/');
            }
            //picBack.ScaleMode = vbTwips
            picBack.BackColor = picGraph.BackColor;
            //g = picBack.CreateGraphics();
            p = new Pen(ColorTranslator.FromWin32(12632256), 1);

            if (picBack.Image == null)
            {
                //picBack.Image= new Bitmap(picBack.Width-4, picBack.Height-4);
                picBack.Image = new Bitmap(picBack.Width, picBack.Height);
            }

            Graphics gBack = Graphics.FromImage(picBack.Image);

            //设置选中的区域***********************************************************
            intBeginFreq = m_intRegionBeginFreq;           

            intEndFreq = m_intRegionEndFreq;
            //intBeginFreq = 500;

            if (intEndFreq > intBeginFreq)
            {
                bsh = new SolidBrush(m_RegionColor);//填充的颜色

                X = intBeginFreq;

                X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
                
                if(X1<13)
                {
                    X1 = 13;
                }
                
                Y1 = 13;

                X = intEndFreq;

                X2 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));

                if(X2<13)
                {
                    X2 = 13;
                }

                Y2 = picBack.Height - 13;

                //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                gBack.FillRectangle(bsh, (float)X1, (float)Y1, (float)(X2 - X1), (float)(Y2 - Y1));
            }

            //***************************************************************

            //显示最大增益区域
            if(m_IsShowMaxGainRegion==true)
            {
                DrawMaxGainRegionGraph(gBack);
            }

            lngScaleHeight = picBack.Height - 2 * 13;//picBack.Height -4- 2 * 13;
            lngScaleWidth = picBack.Width - 2 * 13;//picBack.Width -4- 2 * 13;

            lYSpacingNew = ((float)lngScaleHeight / (m_YMaxValue - m_YMinValue)) * ((m_YMaxValue - m_YMinValue) / m_YPointCount) * m_YGridTick;
            lXSpacingNew = ((float)lngScaleWidth / (m_XMaxValue - m_XMinValue)) * ((m_XMaxValue - m_XMinValue) / m_XPointCount) * m_XGridTick;

            //画网格线
            for (i = 0; i <= (m_YPointCount / m_YGridTick); i++)
            {
                lRetNew = 13 + i * (float)lYSpacingNew;
                if (i % 2 == 0)
                {
                    pt1New.X = 0;
                    pt1New.Y = lRetNew;
                    pt2New.X = (float)picBack.Width;
                    pt2New.Y = (float)lRetNew;

                    p.Color = ColorTranslator.FromWin32(12632256);
                    gBack.DrawLine(p, pt1New, pt2New);
                }
                else
                {
                    pt1New.X = 0;
                    pt1New.Y = lRetNew;
                    pt2New.X = (float)picBack.Width;
                    pt2New.Y = (float)lRetNew;

                    p.Color = ColorTranslator.FromWin32(m_GridColor);
                    gBack.DrawLine(p, pt1New, pt2New);

                }
            }

            p.Color = ColorTranslator.FromWin32(12632256);
            X = 125;
            intCount = 7;
            for (i = 1; i <= intCount; i++)
            {
                if (i != 1)
                {
                    X = X * 2;
                }
                X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
                pt1New.X = (float)X1;
                pt1New.Y = 0;
                pt2New.X = (float)X1;
                pt2New.Y = (float)picBack.Height;
                gBack.DrawLine(p, pt1New, pt2New);
            }

            p.Color = ColorTranslator.FromWin32(m_GridColor);
            X = 250;
            switch (m_XMaxValue)
            {
                case 800:
                    intCount = 4;
                    break;
                case 12000:
                    intCount = 5;
                    break;
                default:
                    intCount = 4;
                    break;
            }
            for (i = 1; i <= intCount; i++)
            {
                if (i == 1)
                {
                    X = X * 3;
                }
                else
                {
                    X = X * 2;
                }
                X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
                pt1New.X = (float)X1;
                pt1New.Y = 0;
                pt2New.X = (float)X1;
                pt2New.Y = (float)picBack.Height;
                gBack.DrawLine(p, pt1New, pt2New);
            }
            //for (i = 0; i <= (m_XPointCount / m_XGridTick); i++)
            //{
            //    lRetNew = 13 + i * lXSpacingNew;

            //    if (i != 1 && i != 3)
            //    {
            //        if (i % 2 == 0)
            //        {
            //            p.Color = ColorTranslator.FromWin32(12632256);
            //            pt1New.X = (float)lRetNew;
            //            pt1New.Y = 0;
            //            pt2New.X = (float)lRetNew;
            //            pt2New.Y = (float)picBack.Height;
            //            gBack.DrawLine(p, pt1New, pt2New);
            //        }
            //        else
            //        {
            //            //p.Color = ColorTranslator.FromWin32(m_GridColor);

            //            //pt1New.X = lRetNew;
            //            //pt1New.Y = 0;
            //            //pt2New.X = lRetNew;
            //            //pt2New.Y = (float)picBack.Height;
            //            //gBack.DrawLine(p, pt1New, pt2New);
            //        }
            //    }
            //}

            //画刻度
            //纵坐标
            if (picXY.Image == null)
            {
                if (picXY.Height==0)
                {
                    picXY.Height = 1;
                }
                picXY.Image = new Bitmap(picXY.Width, picXY.Height);
            }

            Graphics gXY = Graphics.FromImage(picXY.Image);
            if (m_YTitle.Trim() != "")
            {
                pt1.X = 3;
                pt1.Y = 0;

                gXY.DrawString(m_YTitle, new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1);
            }

            j = 0;
            for (i = 0; i <= m_YPointCount; i = i + m_YGridTick)
            {
                if (m_Ynames.Trim() == "")
                {
                    strValue = (m_YMinValue + i * m_YPointValue).ToString();
                }
                else
                {
                    strValue = ArrYNames[i];
                }

                pt1New.X = picBack.Left - gXY.MeasureString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular)).Width - 3;
                pt1New.Y = picBack.Top + 13 + j * lYSpacingNew - gXY.MeasureString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular)).Height / 2;

                gXY.DrawString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1New);
                j = j + 1;
            }

            //横坐标
            j = 0;
            for (i = 0; i <= m_XPointCount; i = i + m_XGridTick)
            {
                if (m_Xnames.Trim() == "")
                {
                    strValue = (m_XMinValue + i * m_XPointValue).ToString();
                }
                else
                {
                    strValue = ArrXNames[i];
                }

                pt1New.X = picBack.Left + 13 + j * lXSpacingNew - gXY.MeasureString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular)).Width / 2;
                pt1New.Y = picBack.Top + picBack.Height + 3;

                gXY.DrawString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1New);
                j = j + 1;
            }

            if (m_XTitle.Trim() != "")
            {
                pt1.X = picBack.Left + picBack.Width;
                pt1.Y = picBack.Top + picBack.Height + 3;

                gXY.DrawString(m_XTitle.Trim(), new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1);
            }


            //picGraph.Image = picBack.Image;
            picGraph.BackgroundImage = picBack.Image;
        }
        private void DrawUpAxis_IO()
        {
            long lRet;
            float lRetNew;
            long lAdjustHeight;
            int i;
            string strValue;
            int j;
            long lYSpacing;
            long lXSpacing;
            float lXSpacingNew;
            float lYSpacingNew;
            //string [] ArrXNames;
            //string [] ArrYNames;
            int lngScaleHeight;
            int lngScaleWidth;
            Graphics g;
            Pen p;
            Brush bsh;
            Point pt1 = new Point();
            Point pt2 = new Point();

            PointF pt1New = new PointF();
            PointF pt2New = new PointF();

            string[] ArrXNames = new string[] { };
            string[] ArrYNames = new string[] { };

            //int intBeginFreq = 0;
            //int intEndFreq = 0;
            //int X = 0;
            //double X1;
            //double Y1;
            //double X2;
            //double Y2;
            //int intCount = 0;

            //////******************************************
            ////m_Xnames = "20/30/40/50/60/70/80/90/100/110/120";
            ////m_Ynames = "120/110/100/90/80/70/60/50";
            //////m_Ynames = "90/80/70/60/50/40/30/20/10";

            ////m_YMaxValue = 120;
            ////m_YMinValue = 50;
            //////m_YMaxValue = 90;
            //////m_YMinValue = 10;

            ////m_XMaxValue = 120;
            ////m_XMinValue = 20;
            ////m_YPointCount = 7;
            ////m_XPointCount = 10;
            //////********************************************

            if (m_Xnames.Trim() != "")
            {
                ArrXNames = m_Xnames.Split('/');
            }
            if (m_Ynames.Trim() != "")
            {
                ArrYNames = m_Ynames.Split('/');
            }
            //picBack.ScaleMode = vbTwips
            picBack.BackColor = picGraph.BackColor;
            //g = picBack.CreateGraphics();
            p = new Pen(ColorTranslator.FromWin32(12632256), 1);

            if (picBack.Image == null)
            {
                //picBack.Image= new Bitmap(picBack.Width-4, picBack.Height-4);
                picBack.Image = new Bitmap(picBack.Width, picBack.Height);
            }

            Graphics gBack = Graphics.FromImage(picBack.Image);

            ////设置选中的区域***********************************************************
            //intBeginFreq = m_intRegionBeginFreq;
            //intEndFreq = m_intRegionEndFreq;

            //if (intEndFreq > intBeginFreq)
            //{
            //    bsh = new SolidBrush(m_RegionColor);//填充的颜色

            //    X = intBeginFreq;

            //    X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
            //    Y1 = 13;

            //    X = intEndFreq;

            //    X2 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
            //    Y2 = picBack.Height - 13;

            //    //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            //    gBack.FillRectangle(bsh, (float)X1, (float)Y1, (float)(X2 - X1), (float)(Y2 - Y1));
            //}

            //***************************************************************
            lngScaleHeight = picBack.Height - 2 * 13;//picBack.Height -4- 2 * 13;
            lngScaleWidth = picBack.Width - 2 * 13;//picBack.Width -4- 2 * 13;

            lYSpacingNew = ((float)lngScaleHeight / (m_YMaxValue - m_YMinValue)) * ((m_YMaxValue - m_YMinValue) / m_YPointCount) * m_YGridTick;
            lXSpacingNew = ((float)lngScaleWidth / (m_XMaxValue - m_XMinValue)) * ((m_XMaxValue - m_XMinValue) / m_XPointCount) * m_XGridTick;

            //画网格线
            for (i = 0; i <= (m_YPointCount / m_YGridTick); i++)
            {
                lRetNew = 13 + i * (float)lYSpacingNew;

                pt1New.X = 0;
                pt1New.Y = lRetNew;
                pt2New.X = (float)picBack.Width;
                pt2New.Y = (float)lRetNew;

                p.Color = ColorTranslator.FromWin32(12632256);
                gBack.DrawLine(p, pt1New, pt2New);

                //if (i % 2 == 0)
                //{
                //    pt1New.X = 0;
                //    pt1New.Y = lRetNew;
                //    pt2New.X = (float)picBack.Width;
                //    pt2New.Y = (float)lRetNew;

                //    p.Color = ColorTranslator.FromWin32(12632256);
                //    gBack.DrawLine(p, pt1New, pt2New);
                //}
                //else
                //{
                //    pt1New.X = 0;
                //    pt1New.Y = lRetNew;
                //    pt2New.X = (float)picBack.Width;
                //    pt2New.Y = (float)lRetNew;

                //    p.Color = ColorTranslator.FromWin32(12632256);
                //    //p.Color = ColorTranslator.FromWin32(m_GridColor);
                //    gBack.DrawLine(p, pt1New, pt2New);

                //}
            }

            for (i = 0; i <= (m_XPointCount / m_XGridTick); i++)
            {
                lRetNew = 13 + i * (float)lXSpacingNew;
                pt1New.X = lRetNew;
                pt1New.Y = 0;
                pt2New.X = lRetNew; //(float)picBack.Width;
                pt2New.Y = (float)picBack.Height; //(float)lRetNew;

                p.Color = ColorTranslator.FromWin32(12632256);
                gBack.DrawLine(p, pt1New, pt2New);
            }

            //p.Color = ColorTranslator.FromWin32(12632256);
            //X = 125;
            //intCount = 7;
            //for (i = 1; i <= intCount; i++)
            //{
            //    if (i != 1)
            //    {
            //        X = X * 2;
            //    }
            //    X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
            //    pt1New.X = (float)X1;
            //    pt1New.Y = 0;
            //    pt2New.X = (float)X1;
            //    pt2New.Y = (float)picBack.Height;
            //    gBack.DrawLine(p, pt1New, pt2New);
            //}

            //p.Color = ColorTranslator.FromWin32(m_GridColor);
            //X = 250;
            //switch (m_XMaxValue)
            //{
            //    case 800:
            //        intCount = 4;
            //        break;
            //    case 12000:
            //        intCount = 5;
            //        break;
            //    default:
            //        intCount = 4;
            //        break;
            //}
            //for (i = 1; i <= intCount; i++)
            //{
            //    if (i == 1)
            //    {
            //        X = X * 3;
            //    }
            //    else
            //    {
            //        X = X * 2;
            //    }
            //    X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picBack.Width - 2 * 13));
            //    pt1New.X = (float)X1;
            //    pt1New.Y = 0;
            //    pt2New.X = (float)X1;
            //    pt2New.Y = (float)picBack.Height;
            //    gBack.DrawLine(p, pt1New, pt2New);
            //}
            //for (i = 0; i <= (m_XPointCount / m_XGridTick); i++)
            //{
            //    lRetNew = 13 + i * lXSpacingNew;

            //    if (i != 1 && i != 3)
            //    {
            //        if (i % 2 == 0)
            //        {
            //            p.Color = ColorTranslator.FromWin32(12632256);
            //            pt1New.X = (float)lRetNew;
            //            pt1New.Y = 0;
            //            pt2New.X = (float)lRetNew;
            //            pt2New.Y = (float)picBack.Height;
            //            gBack.DrawLine(p, pt1New, pt2New);
            //        }
            //        else
            //        {
            //            //p.Color = ColorTranslator.FromWin32(m_GridColor);

            //            //pt1New.X = lRetNew;
            //            //pt1New.Y = 0;
            //            //pt2New.X = lRetNew;
            //            //pt2New.Y = (float)picBack.Height;
            //            //gBack.DrawLine(p, pt1New, pt2New);
            //        }
            //    }
            //}

            //画刻度
            //纵坐标
            if (picXY.Image == null)
            {
                picXY.Image = new Bitmap(picXY.Width, picXY.Height);
            }

            Graphics gXY = Graphics.FromImage(picXY.Image);
            if (m_YTitle.Trim() != "")
            {
                pt1.X = 3;
                pt1.Y = 0;

                gXY.DrawString(m_YTitle, new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1);
            }

            j = 0;
            for (i = 0; i <= m_YPointCount; i = i + m_YGridTick)
            {
                if (m_Ynames.Trim() == "")
                {
                    strValue = (m_YMinValue + i * m_YPointValue).ToString();
                }
                else
                {
                    strValue = ArrYNames[i];
                }

                pt1New.X = picBack.Left - gXY.MeasureString(strValue, new Font(fontfamily, fontsize)).Width - 3;
                pt1New.Y = picBack.Top + 13 + j * lYSpacingNew - gXY.MeasureString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular)).Height / 2;

                gXY.DrawString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1New);
                j = j + 1;
            }

            //横坐标
            j = 0;
            for (i = 0; i <= m_XPointCount; i = i + m_XGridTick)
            {
                if (m_Xnames.Trim() == "")
                {
                    strValue = (m_XMinValue + i * m_XPointValue).ToString();
                }
                else
                {
                    strValue = ArrXNames[i];
                }

                pt1New.X = picBack.Left + 13 + j * lXSpacingNew - gXY.MeasureString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular)).Width / 2;
                pt1New.Y = picBack.Top + picBack.Height + 3;

                gXY.DrawString(strValue, new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1New);
                j = j + 1;
            }

            if (m_XTitle.Trim() != "")
            {
                pt1.X = picBack.Left + picBack.Width;
                pt1.Y = picBack.Top + picBack.Height + 3;

                gXY.DrawString(m_XTitle.Trim(), new Font(fontfamily, fontsize,FontStyle.Regular), new SolidBrush(m_FontNormalColor), pt1);
            }


            //picGraph.Image = picBack.Image;
            picGraph.BackgroundImage = picBack.Image;
        }

        private void picGraph_Click(object sender, EventArgs e)
        {

        }
        private void picXY_Click(object sender, EventArgs e)
        {

        }
        private void picXY_MouseMove(object sender, MouseEventArgs e)
        {
            //MousePointer = vbDefault
            //picXYInfo.Visible = False
            this.Cursor = Cursors.Default;
            pnlXYInfo.Visible = false;

        }
        private void picGraph_MouseDown(object sender, MouseEventArgs e)
        {
        }
        private void picGraph_MouseMove(object sender, MouseEventArgs e)
        {
        }

        private void ctlHCurve_Resize(object sender, EventArgs e)
        {
            ResizeControl();
        }

        //调整位置
        private void ResizeControl()
        {
            //picXY
            picXY.Left = 0;
            picXY.Top = 0;
            picXY.Width = this.Width;
            picXY.Height = this.Height;

            //picGraph
            picGraph.Left = 33;
            picGraph.Top = 13;
            if ((picXY.Width - 2 * picGraph.Left) >= 0)
            {
                picGraph.Width = picXY.Width - 2 * picGraph.Left;
            }
            if ((picXY.Height - picGraph.Top - 24) >= 0)
            {
                picGraph.Height = picXY.Height - picGraph.Top - 24;
            }

            //picBack
            picBack.Left = picGraph.Left;
            picBack.Top = picGraph.Top;
            picBack.Width = picGraph.Width;
            picBack.Height = picGraph.Height;

            //重画坐标和图形
            RefreshGraph();
        }

        //**********************************
        // 刷新图形
        //**********************************
        public void RefreshGraph()
        {
            //重画坐标和图形
            switch (m_CurveType)
            {
                case CurveTypeS.Client:
                    ClearAxis();
                    //ClearGraph();
                    DrawUpAxis();

                    DrawCurves();

                    //RefreshLossCurves();
                    break;
                case CurveTypeS.IO:
                    ClearAxis();
                    DrawUpAxis();
                    DrawCurves();
                    break;
                case CurveTypeS.Product:
                    //RefreshProArea();
                    break;
                case CurveTypeS.Stimulate:
                    //RefreshStimulate();
                    break;
                default:
                    break;
            }
        }

        //添加线条
        public void AddCurve()//(int Index,int[] pvFreqList,double[] pvPointValues)
        {
            Curve myCurve = new Curve();
            mvarCurveList.Add(myCurve);
        }
        public void RemoveCurve(int pvIndex)
        {
            Curve myCurve = mvarCurveList[pvIndex];
            mvarCurveList.Remove(myCurve);
        }
        public void RemoveAllCurve()
        {
            mvarCurveList.Clear();
        }

        //画线
        public void DrawCurves()
        {
            switch (m_CurveType)
            {
                case CurveTypeS.Client:
                    DrawFreqGainCurves();
                    break;

                case CurveTypeS.IO:
                    DrawIOCurves();
                    break;
                default:
                    DrawFreqGainCurves();
                    break;
            }
        }
        public void DrawIOCurves()
        {
            int i = 0;
            int j = 0;
            int intCurveCount = 0;
            double X1 = 0;
            double Y1 = 0;
            double X2 = 0;
            double Y2 = 0;
            int X = 0;
            double Y = 0;

            Graphics g;
            Pen p;

            if (picGraph.Image != null)
            {
                picGraph.Image.Dispose();
                picGraph.Image = null;
            }

            if (picGraph.Image == null)
            {
                picGraph.Image = new Bitmap(picGraph.Width, picGraph.Height);
            }

            //picGraph.Image = picBack.Image;

            Graphics gGraph = Graphics.FromImage(picGraph.Image);

            //画线

            intCurveCount = mvarCurveList.Count;
            for(i=0;i<intCurveCount;i++)
            {

                //画图对象
                p = new Pen(mvarCurveList[i].CurveColor, (float)mvarCurveList[i].CurveWith);
                if(mvarCurveList[i].CurveStyle=="Solid")
                {
                    p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                }
                else
                {
                    p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                }                

                for (j = 0; j < mvarCurveList[i].PointCount-1; j++)
                {
                    X = mvarCurveList[i].Points[j].X;
                    Y = mvarCurveList[i].Points[j].Y;
                    X1 = (double)(13+((float)(X-m_XMinValue)/(float)(m_XMaxValue-m_XMinValue)*(picGraph.Width-2*13)));
                    Y1= (double)(13 + (float)(picGraph.Height - 2 * 13) - ((float)(picGraph.Height - 2 * 13) / (m_YMaxValue - m_YMinValue)) * (Y - m_YMinValue));

                    X = mvarCurveList[i].Points[j+1].X;
                    Y = mvarCurveList[i].Points[j+1].Y;
                    X2 = (double)(13 + ((float)(X - m_XMinValue) / (float)(m_XMaxValue - m_XMinValue) * (picGraph.Width - 2 * 13)));
                    Y2 = (double)(13 + (float)(picGraph.Height - 2 * 13) - ((float)(picGraph.Height - 2 * 13) / (m_YMaxValue - m_YMinValue)) * (Y - m_YMinValue));
                    
                    if (((Y1 > picGraph.Height - 13) && (Y2 >= picGraph.Height - 13)) || ((Y1 >= picGraph.Height - 13) && (Y2 > picGraph.Height - 13)))
                    {

                    }
                    //if ((Y1 > picGraph.Height - 13) && (Y2 > picGraph.Height - 13))
                    //{

                    //}
                    else
                    {
                        if((Y1>picGraph.Height-13) && (Y2<picGraph.Height-13))
                        {
                            X1 = X2 - (picGraph.Height - 13-Y2) * (X2 - X1) / (Y1 - Y2);
                            Y1 = picGraph.Height - 13;
                        }
                        if ((Y1 < picGraph.Height - 13) && (Y2 > picGraph.Height - 13))
                        {
                            X2 = X2 - (Y2 - picGraph.Height + 13) * (X2 - X1) / (Y2 - Y1);
                            Y2 = picGraph.Height - 13;
                        }
                        gGraph.DrawLine(p, (float)X1, (float)Y1, (float)X2, (float)Y2);
                    }
                }

                p.Dispose();

            }

            gGraph.Dispose();
            gGraph = null;

        }

        public void DrawFreqGainCurves()
        {
            int i = 0;
            int j = 0;
            int intCurveCount = 0;
            double X1 = 0;
            double Y1 = 0;
            double X2 = 0;
            double Y2 = 0;
            int X = 0;
            double Y = 0;

            Graphics g;
            Pen p;
            Brush bsh;
           
            picGraph.Image = null;
            if (picGraph.Image == null)
            {
                picGraph.Image = new Bitmap(picGraph.Width, picGraph.Height);
            }

            //picGraph.Image = picBack.Image;

            Graphics gGraph = Graphics.FromImage(picGraph.Image);

            //去掉锯齿
            gGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            //画线

            intCurveCount = mvarCurveList.Count;
            for (i = 0; i < intCurveCount; i++)
            {

                //画图对象
                p = new Pen(mvarCurveList[i].CurveColor, (float)mvarCurveList[i].CurveWith);
                if (mvarCurveList[i].CurveStyle == "Solid")
                {
                    p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                }
                else
                {
                    //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                    //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;


                    float[] dashArray = {
                        3.0f,  //线长5个像素                
                        3.0f,  //间断2个像素                
                        3.0f, //线长15个像素                
                        3.0f   //间断4个像素                               
                    };

                    p.DashPattern = dashArray;



                }

                for (j = 0; j < mvarCurveList[i].PointCount - 1; j++)
                {
                    X = mvarCurveList[i].Points[j].X;
                    Y = mvarCurveList[i].Points[j].Y;
                    if(Y==double.NaN)
                    {
                        Y = 120;
                    }
                    X1 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picGraph.Width - 2 * 13));
                    Y1 = (double)(13 + (float)(picGraph.Height - 2 * 13) - ((float)(picGraph.Height - 2 * 13) / (m_YMaxValue - m_YMinValue)) * (Y - m_YMinValue));

                    X = mvarCurveList[i].Points[j + 1].X;
                    Y = mvarCurveList[i].Points[j + 1].Y;
                    X2 = (double)(13 + (Math.Log((float)(X) / 125) / Math.Log(2)) / (Math.Log((float)m_XMaxValue / 125) / Math.Log(2)) * (picGraph.Width - 2 * 13));
                    Y2 = (double)(13 + (float)(picGraph.Height - 2 * 13) - ((float)(picGraph.Height - 2 * 13) / (m_YMaxValue - m_YMinValue)) * (Y - m_YMinValue));

                    if (((Y1 > picGraph.Height - 13) && (Y2 >= picGraph.Height - 13)) || ((Y1 >= picGraph.Height - 13) && (Y2 > picGraph.Height - 13)))
                    {

                    }
                    //if ((Y1 > picGraph.Height - 13) && (Y2 > picGraph.Height - 13))
                    //{

                    //}
                    else
                    {
                        if ((Y1 > picGraph.Height - 13) && (Y2 < picGraph.Height - 13))
                        {
                            X1 = X2 - (picGraph.Height - 13 - Y2) * (X2 - X1) / (Y1 - Y2);
                            Y1 = picGraph.Height - 13;
                        }
                        if ((Y1 < picGraph.Height - 13) && (Y2 > picGraph.Height - 13))
                        {
                            X2 = X2 - (Y2 - picGraph.Height + 13) * (X2 - X1) / (Y2 - Y1);
                            Y2 = picGraph.Height - 13;
                        }
                        gGraph.DrawLine(p, (float)X1, (float)Y1, (float)X2, (float)Y2);
                    }
                }
            }
        }

        public void SetFreqList(int[] pvFreqList)
        {
            mArrFreqList = pvFreqList;
            MessageBox.Show(mArrFreqList[0].ToString());
        }

        //取得图片
        public Image GetCurveGraph(int pvWidth, int pvHeigh)
        {
            Image imgGraph = null;

            this.Width = pvWidth;
            this.Height = pvHeigh;

            ResizeControl();



            picXY.Width = this.Width;
            picXY.Height = this.Height;

            imgGraph = MergeImages();

            return imgGraph;


        }

        //合并图片
        private Image MergeImages()
        {
            //Image img = Image.FromFile(workpath + @"\i\PanelSave.png");
            Image img = picXY.Image;
            Image img1 = picBack.Image;
            Image img2 = picGraph.Image;

            Bitmap backimg = new Bitmap(img.Width, img.Height);

            SolidBrush my = new SolidBrush(picGraph.BackColor);
            Graphics graphics = Graphics.FromImage(backimg);
            graphics.FillRectangle(my, 0, 0, img.Width, img.Height);
            graphics.DrawImage(img, new PointF(0, 0));
            graphics.DrawImage(img1, new PointF(33, 13));
            if (img2 != null) graphics.DrawImage(img2, new PointF(33, 13));

            return backimg;

        }
    }

    //点的类
    public class CurvePoint
    {
        private int x = 0;
        private double y = 0;

        //构造函数
        public CurvePoint()
        {

        }

        public CurvePoint(int pvX,double pvY)
        {
            x = pvX;
            y = pvY;
        }

        public int X
        {
            get
            {
                return x;
            }
            set
            {
                x = value;
            }
        }
        public double Y
        {
            get
            {
                return y;
            }
            set
            {
                y = value;
            }
        }
    }

    public class PointList:List<CurvePoint>
    {

    }

    public class Curve
    {
        private Color mvarCurveColor = Color.Black;
        private int mvarCurveWith = 1;
        private PointList mvarPoints = new PointList();
        private int mvarPointCount = 0;
        private string mvarCurveStyle = "Solid";//Solid:实线 Dot:点
        //线的颜色
        public Color CurveColor
        {
            get
            {
                return mvarCurveColor;
            }
            set
            {
                mvarCurveColor = value;
            }
        }
        //线的宽度
        public int CurveWith
        {
            get
            {
                return mvarCurveWith;
            }
            set
            {
                mvarCurveWith = value;
            }
        }
        //点的个数
        public int PointCount
        {
            get
            {
                return mvarPointCount;
            }
            set
            {
                mvarPointCount = value;
            }
        }

        //点的样式
        public string CurveStyle
        {
            get
            {
                return mvarCurveStyle;
            }
            set
            {
                mvarCurveStyle = value;
            }
        }

        //点的集合
        public PointList Points
        {
            get
            {
                return mvarPoints;
            }
        }

        public void AddPoint(int pvX,double pvY)
        {
            CurvePoint myPoint = new CurvePoint(pvX,pvY);
            mvarPoints.Add(myPoint);
        }
        public void RemovePoint(int pvIndex)
        {
            CurvePoint myPoint = mvarPoints[pvIndex];
            mvarPoints.Remove(myPoint);
        }
        public void RemoveAllPoint()
        {
            mvarPoints.Clear();
        }
    }
    public class CurveList : List<Curve>
    {

    }

}